package com.ruge.user.controller;

import com.ruge.core.response.Response;
import com.ruge.user.domain.request.BlobFollowRequest;
import com.ruge.user.domain.request.ListBlogRequest;
import com.ruge.user.domain.request.SavaBlogRequest;
import com.ruge.user.service.BlogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ruge.wu
 * @since 2022/2/9 15:46
 */
@Slf4j
@RestController
@Api(tags = "【微博 相关接口】", value = "【微博 相关接口】")
@RequestMapping("blog")
public class BlogController {

    @Resource
    private BlogService blogService;

    @PostMapping("save")
    @ApiOperation(value = "【微博】  新建博客同时推送给订阅者 feed")
    public Response save(@RequestBody SavaBlogRequest request) {
        return blogService.save(request);
    }

    @PostMapping("delete")
    @ApiOperation(value = "【微博】  删除博客", notes = "同时清理掉推送给订阅者的数据信息 清理feed")
    public Response delete(@ApiParam(value = "文章id") @RequestParam("blogId") Long blogId) {
        return blogService.delete(blogId);
    }

    @PostMapping("pipline")
    @ApiOperation(value = "【微博】  推送操作", notes = "新增推送或取消推送 源头为关注和取关")
    public Response pipline(@RequestBody BlobFollowRequest request) {
        return blogService.pipline(request);
    }

    @GetMapping("getMySub")
    @ApiOperation(value = "【微博】  查看我的订阅", notes = "我的订阅")
    public Response getMySub(@Validated @RequestBody ListBlogRequest request) {
        return blogService.getMySub(request);
    }
}
